# -*- encoding=utf8 -*-
"""
RedFlag-TC000096   （拍摄进入装饰页）剪辑变速功能
使用小于1倍速功能场景
使用大于1倍速功能场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *

auto_setup(__file__)
shooter = CameraVideoShooter()

log("--------------------------------使用小于1倍速功能场景--------------------------------------")
"""
拍摄视频进入装饰页
点击剪辑
获取初始速度文本值
点击变速
点击小于一倍速的任意点
点击取消
获取此时时间文本值
断言
点击变速
点击小于一倍速的任意点
点击确认
获取此时时间文本值
断言
"""
shooter.enter_photography_decoration_page()
shooter.click_element(edit_button)
sleep(1.0)
variable_speed_old_text = shooter.get_element_text(edit_total_first_paragraph)
shooter.click_element(edit_variable_speed)
touch((0.12,0.93))
shooter.click_element(edit_variable_speed_cancel)
variable_speed_old_text1 = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
shooter.assert_texts_equal(variable_speed_old_text, variable_speed_old_text1, "断言失败，比对两值不相等")
shooter.click_element(edit_variable_speed)
touch((0.12,0.93))
shooter.click_element(edit_variable_speed_confirm)
variable_speed_new_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
shooter.assert_compare(variable_speed_old_text,variable_speed_new_text,compare_type="lt",message="断言失败，比对值与预期结果不一样"  )

log("--------------------------------使用大于1倍速功能场景--------------------------------------")
"""
点击变速
点击大于一倍速的任意点
点击确认
获取此时时间文本值
断言
"""
shooter.click_element(edit_variable_speed)
touch((0.45,0.93))
shooter.click_element(edit_variable_speed_confirm)
variable_speed_new_text1 = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clipTimeTV"))
shooter.assert_compare(variable_speed_old_text, variable_speed_new_text1, "gt", "断言失败，比对值与预期结果不一样")

# 关闭应用
stop_app(UGC_package_name)